package com.fare.taluo.vo.immediately;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.fare.taluo.util.DateUtils;

public class FreightPriceVO implements Comparable<FreightPriceVO>{

	/**
	 * 运营商简称英文，如：MU
	 */
	private String carrierKey;

	/**
	 * 运营商简称中文，如：南航
	 */
	private String carrierName;
	/**
	 * 航班批次日期。如:2012-05-19,格式:yyyy-MM-dd
	 */
	private String flightDate;

	/**
	 * 航班起飞时间
	 */
	private Date startTime;

	/**
	 * 航班预计到达时间
	 */
	private Date endTime;

	/**
	 * 航班号，如： MU3540
	 */
	private String flightNo;

	/**
	 * 目的地三字码
	 */
	private String toCity;
	/**
	 * 目的地名称
	 */
	private String toCityName;
	/**
	 * 区域码
	 */
	private String areaCode;
	/**
	 * 区域名称
	 */
	private String areaName;
	/**
	 * 起飞地三字码
	 * 
	 */
	private String fromCity;
	/**
	 * 起飞地
	 * 
	 */
	private String fromCityName;

	/**
	 * 最低价格
	 */
	private Double lowerPrice;

	/**
	 * 最低价代理商名称
	 */
	private String agentName;

	/**
	 * 最高价格
	 */
	private Double highPrice;
	/**
	 * 附加的hbase应用值，用于生成rowkey,以便于应用根据该值统计
	 * <p>实际上使用下面的"抓取渠道ID"也可，但基于应用已完成部分功能，补充上该值
	 */
	private String attachHbaseKey;
	/**
	 * 抓取渠道ID
	 * */
	private Long grabChannelId;
	/**
	 * 抓取渠道名称
	 */
	private String grabChannel;
	
	/**
	 * 飞机类型
	 */
	private String flightType;

	public FreightPriceVO(){}
	
	public FreightPriceVO(String carrierKey, String carrierName,
			String flightDate, Date startTime, Date endTime, String flightNo,
			String toCity, String toCityName, String areaCode, String areaName,
			String fromCity, String fromCityName, Double lowerPrice,
			String agentName, Double highPrice, String attachHbaseKey,
			Long grabChannelId, String grabChannel, String flightType) {
		super();
		this.carrierKey = carrierKey==null?"":carrierKey;
		this.carrierName = carrierName==null?"":carrierName;
		this.flightDate = flightDate==null?"":flightDate;
		this.startTime = startTime==null?new Date(0):startTime;
		this.endTime = endTime==null?new Date(0):endTime;
		this.flightNo = flightNo==null?"":flightNo;
		this.toCity = toCity==null?"":toCity;
		this.toCityName = toCityName==null?"":toCityName;
		this.areaCode = areaCode==null?"":areaCode;
		this.areaName = areaName==null?"":areaName;
		this.fromCity = fromCity==null?"":fromCity;
		this.fromCityName = fromCityName==null?"":fromCityName;
		this.lowerPrice = lowerPrice;
		this.agentName = agentName==null?"":agentName;
		this.highPrice = highPrice;
		this.attachHbaseKey = attachHbaseKey==null?"":attachHbaseKey;
		this.grabChannelId = grabChannelId;
		this.grabChannel = grabChannel==null?"":grabChannel;
		this.flightType = flightType==null?"":flightType;
	}

	public String getCarrierKey() {
		return carrierKey;
	}

	public void setCarrierKey(String carrierKey) {
		this.carrierKey = carrierKey;
	}

	public String getCarrierName() {
		return carrierName;
	}

	public void setCarrierName(String carrierName) {
		this.carrierName = carrierName;
	}

	public String getFlightDate() {
		return flightDate;
	}

	public void setFlightDate(String flightDate) {
		this.flightDate = flightDate;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getFlightNo() {
		return flightNo;
	}

	public void setFlightNo(String flightNo) {
		this.flightNo = flightNo;
	}

	public String getToCity() {
		return toCity;
	}

	public void setToCity(String toCity) {
		this.toCity = toCity;
	}

	public String getToCityName() {
		return toCityName;
	}

	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getFromCity() {
		return fromCity;
	}

	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}

	public String getFromCityName() {
		return fromCityName;
	}

	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}

	public Double getLowerPrice() {
		return lowerPrice;
	}

	public void setLowerPrice(Double lowerPrice) {
		this.lowerPrice = lowerPrice;
	}

	public String getAgentName() {
		return agentName;
	}

	public void setAgentName(String agentName) {
		this.agentName = agentName;
	}

	public Double getHighPrice() {
		return highPrice;
	}

	public void setHighPrice(Double highPrice) {
		this.highPrice = highPrice;
	}

	public String getAttachHbaseKey() {
		return attachHbaseKey;
	}

	public void setAttachHbaseKey(String attachHbaseKey) {
		this.attachHbaseKey = attachHbaseKey;
	}

	public Long getGrabChannelId() {
		return grabChannelId;
	}

	public void setGrabChannelId(Long grabChannelId) {
		this.grabChannelId = grabChannelId;
	}

	public String getGrabChannel() {
		return grabChannel;
	}

	public void setGrabChannel(String grabChannel) {
		this.grabChannel = grabChannel;
	}

	public String getFlightType() {
		return flightType;
	}

	public void setFlightType(String flightType) {
		this.flightType = flightType;
	}

	public String getFlightInfo(){
		return new StringBuilder("航班号:").append(this.getFlightNo()).append("\n")
				.append("机型:").append(StringUtils.isNotBlank(this.getFlightType()) ? this.getFlightType() : "").append("\n")
				.append("起飞城市:")
				.append(this.getFromCityName().indexOf("(") > -1 ? this.getFromCityName().substring(0,  this.getFromCityName().indexOf("(")) : this.getFromCityName())
				.append("(").append(this.getFromCity()).append(")").append("\n")
				.append("到达城市:")
				.append(this.getToCityName().indexOf("(") > -1 ? this.getToCityName().substring(0, this.getToCityName().indexOf("(")) : this.getToCityName())
				.append("(").append(this.getToCity()).append(")").append("\n")
				.append("起飞时间:").append(DateUtils.formatTime(this.getStartTime(),"HH:mm")).append("\n")
				.append("到达时间:").append(DateUtils.formatTime(this.getEndTime(),"HH:mm")).toString();
	}
	@Override
	public int compareTo(FreightPriceVO o) {
		return this.getCarrierKey().compareTo(o.getCarrierKey()) == 0 ? 
				this.getLowerPrice().compareTo(o.getLowerPrice()) : this.getCarrierKey().compareTo(o.getCarrierKey());
	}
	
	
}
